- | = esc_html( $event->getEventTitle() ) ?> |
+ hasConferenceEventsURL() ) {
+
+ // print the Event permalink
+ echo HTML::a(
+ $event->getEventURL(),
+ esc_html( $event->getEventTitle() )
+ );
+ } else {
+
+ // just print the Event title
+ echo esc_html( $event->getEventTitle() );
+ }
+ ?> |
= esc_html( $event->getConferenceTitle() ) ?> |
= esc_html( $event->getLocationName() ) ?>
|
%s (il %s)"),
$event->getEventStart("H:i"),
$event->getEventStart("d/m/Y")
) ?>
= $event->getEventHumanStart() ?>
|
isUserSocial() ): ?>
= __("Social") ?>
has( User::RSS ) and UserSocialBox::spawn( $user, "RSS", $user->get( User::RSS ), 'home.png' );
$user->has( User::FACEBOOK ) and UserSocialBox::spawn( $user, "Facebook", $user->getUserFacebruck(), 'facebook_logo.png' );
$user->has( User::GOOGLE_PLUS ) and UserSocialBox::spawn( $user, "Google+", $user->getUserGuggolpluz(), 'google.png' );
$user->has( User::TWITTER ) and UserSocialBox::spawn( $user, "Twitter", $user->getUserTuitt(), 'twitter.png' );
$user->has( User::LINKEDIN ) and UserSocialBox::spawn( $user, "Linkedin", $user->getUserLinkeddon(), 'linkedin.png' );
$user->has( User::GITHUB ) and UserSocialBox::spawn( $user, "Github", $user->getUserGithubbo(), 'github.png' );
?>
.
trait ConferenceTrait {
/**
* Get conference ID
*
* @return int
*/
public function getConferenceID() {
return $this->nonnull( Conference::ID );
}
/**
* Get conference UID
*
* @return string
*/
function getConferenceUID() {
return $this->get( Conference::UID );
}
/**
* Get localized conference title
*
* @return string
*/
public function getConferenceTitle() {
return __( $this->get( Conference::TITLE ) );
}
function getConferenceURL( $base = URL ) {
return $base . sprintf( PERMALINK_CONFERENCE, $this->getConferenceUID() );
}
+ /**
+ * Check if the Conference has URLs for every Event
+ *
+ * @return boolean
+ */
+ public function hasConferenceEventsURL() {
+ return $this->has( 'conference_events_url' );
+ }
+
function forceConferencePermalink() {
$url = $this->getConferenceURL( ROOT );
if( $url !== $_SERVER['REQUEST_URI'] ) {
http_redirect( $url );
}
}
function getConferenceHumanStart() {
return HumanTime::diff( $this->getConferenceStart() );
}
function getConferenceHumanEnd() {
return HumanTime::diff( $this->getConferenceEnd() );
}
/**
* Get the Conference date start
*
* @param string $format If specified, return the formatted date
* @return DateTime|string
*/
public function getConferenceStart( $format = null ) {
$date = $this->get( 'conference_start' );
if( $format ) {
return $date->format( $format );
}
return $date;
}
/**
* Get the Conference date end
*
* @param string $format If specified, return the formatted date
*/
public function getConferenceEnd( $format = null ) {
$date = $this->get( 'conference_end' );
if( $format ) {
return $date->format( $format );
}
return $date;
}
/**
* Get URL to trop-iCal API for this conference
*
* @param boolean $absolute Set to true for an absolute URL
* @return string
*/
function getConferenceCalURL( $absolute = false ) {
$conf = urlencode( $this->getConferenceUID() );
return site_page( "api/tropical.php?conference=$conf", $absolute );
}
/**
* Get localized conference description
*
* @return string
*/
public function getConferenceDescription() {
return nl2br( __( $this->get( Conference::DESCRIPTION ) ) );
}
/**
* Get localized conference quote
*
* @return string
*/
public function getConferenceQuote() {
return nl2br( __( $this->get( 'conference_quote' ) ) );
}
/**
* Get localized conference subtitle
*
* @return string
*/
public function getConferenceSubtitle() {
return __( $this->get( Conference::SUBTITLE ) );
}
/**
* Factory a FullEvent by this conference
*
* @return Query
*/
public function factoryFullEventByConference() {
return FullEvent::factoryByConference( $this->getConferenceID() );
}
/**
* Get the URL to create an Event in this Conference
*
* @param boolean $absolute Flag to have an absolute URL
* @return string
*/
public function getURLToCreateEventInConference( $args = [], $absolute = false ) {
$args['conference'] = $this->getConferenceUID();
return FullEvent::editURL( $args, $absolute );
}
/**
* Normalize a Conference object
*/
protected function normalizeConference() {
$this->integers(
Conference::ID,
Conference::DAYS,
Location::ID
);
$this->datetimes(
Conference::START,
Conference::END
);
}
}
/**
* A Conference is an event in a certain Location
*/
class Conference extends Queried {
use ConferenceTrait;
/**
* Database table name
*/
const T = 'conference';
/**
* Conference ID column
*/
const ID = 'conference_ID';
/**
* Conference UID column
*/
const UID = 'conference_uid';
/**
* Conference title column
*/
const TITLE = 'conference_title';
/**
* Subtitle column name
*/
const SUBTITLE = 'conference_subtitle';
/**
* Description column name
*/
const DESCRIPTION = 'conference_description';
/**
* Start column name
*/
const START = 'conference_start';
/**
* End column name
*/
const END = 'conference_end';
/**
* Acronym column name
*/
const ACRONYM = 'conference_acronym';
/**
* Persons URL column name
*/
const PERSONS_URL = 'conference_persons_url';
/**
* Events URL column name
*/
const EVENTS_URL = 'conference_events_url';
/**
* Days column name
*/
const DAYS = 'conference_days';
/**
* Complete ID column name
*/
const ID_ = self::T . DOT . self::ID;
/**
* Complete Location ID column name
*/
const LOCATION_ = self::T . DOT . Location::ID;
/**
* Maximum UID length
*
* @override
*/
const MAXLEN_UID = 32;
/**
* Constructor
*/
public function __construct() {
$this->normalizeConference();
}
}
diff --git a/includes/class-QueryEvent.php b/includes/class-QueryEvent.php
index bd61c8d..2cada45 100644
--- a/includes/class-QueryEvent.php
+++ b/includes/class-QueryEvent.php
@@ -1,143 +1,156 @@
.
/**
* Class able to query a FullEvent.
*/
class QueryEvent extends Query {
+ /**
+ * Univoque Chapter ID column name
+ *
+ * @var
+ */
+ protected $CHAPTER_ID = 'event.chapter_ID';
+
/**
* Constructor
*/
public function __construct() {
parent::__construct();
$this->from( Event::T );
$this->defaultClass( FullEvent::class );
}
/**
* Limit to a certain User
*
* @param $user User
* @return self
*/
public function whereUser( $user ) {
return $this->joinEventUser()
->whereInt( EventUser::USER_, $user->getUserID() );
}
/**
* Limit to a specific Conference
*
* @param $conference Conference
* @return self
*/
public function whereConference( $conference ) {
return $this->joinConference()
->whereInt( Event::CONFERENCE_, $conference->getConferenceID() );
}
/**
* Exclude a specific Conference
*
* @param $conference Conference
* @return self
*/
public function whereConferenceNot( $conference ) {
+ $id = $conference->getConferenceID();
return $this->joinConference()
- ->where( sprintf(
- "%s <> %d",
- Event::CONFERENCE_,
- $conference->getConferenceID()
- ) );
+ ->whereInt( Event::CONFERENCE_, $id, '<>' );
}
/**
* Join Events to their Conference
*
* You can call it multiple time safely.
*
* @return self
*/
public function joinConference() {
if( empty( $this->joinedConference ) ) {
$this->from( Conference::T );
$this->equals( Conference::ID_, Event::CONFERENCE_ );
$this->joinedConference = true;
}
return $this;
}
+ /**
+ * Join a table with the Chapter table
+ *
+ * @return self
+ */
+ public function joinChapter() {
+ return $this->joinOn( 'INNER', 'chapter', 'chapter.chapter_ID' , $this->CHAPTER_ID );
+ }
+
/**
* Join Events to their Location (and Conference. asd)
*
* You can call it multiple time safely.
*
* @TODO: move this method into QueryConference, and extends QueryEvent
* @return self
*/
public function joinLocation() {
$this->joinConference();
if( empty( $this->joinedLocation ) ) {
$this->from( Location::T );
$this->equals( Location::ID_, Conference::ID_ );
$this->joinedLocation = true;
}
return $this;
}
/**
* Join Events to User IDs
*
* You can call it multiple time safely.
*
* @return self
*/
public function joinEventUser() {
if( empty( $this->joinedEventUser ) ) {
$this->from( EventUser::T );
$this->equals( EventUser::EVENT_, Event::ID_ );
$this->joinedEventUser = true;
}
return $this;
}
/**
* Join Events and their Track, Chapter and Room (can be NULL).
*
* You can call it multiple time safely.
*
* @return self
*/
public function joinTrackChapterRoom() {
if( empty( $this->joinedTrackChapterRoom ) ) {
$this->from( Room::T )
->equals( Room::ID_, Event::ROOM_ );
$this->from( Track::T )
->equals( Track::ID_, Event::TRACK_ );
$this->from( Chapter::T )
->equals( Chapter::ID_, Event::CHAPTER_ );
$this->joinedTrackChapterRoom = true;
}
return $this;
}
}